package yunplus.io.hchome.model.api.implement;

import android.support.annotation.NonNull;

import com.alibaba.fastjson.JSONObject;

import yunplus.io.hchome.model.api.contract.IInput;

/**
 * Created by WangFan on 2017/5/16.
 */

public class FPMInput extends JSONObject implements IInput {
    private int _code;
    private String _user;
    private JSONObject _args;

    public FPMInput(@NonNull int code, @NonNull String user, @NonNull JSONObject args){
        _code = code;
        _user = user;
        _args = args;
    }

    public FPMInput(@NonNull int code, @NonNull String user){
        _code = code;
        _user = user;
    }

    @Override
    public int getCode() {
        return _code;
    }

    @Override
    public String getUser() {
        return _user;
    }

    @Override
    public JSONObject getArgs() {
        return _args == null?_args = new JSONObject():_args;
    }

    @Override
    public String toJson() {
        this.put("id", -1);
        this.put("code", getCode());
        this.put("user", getUser());
        this.put("args", getArgs());
        return this.toJSONString();
    }
}
